<?php
class PortfolioController extends Sosweb_Controller_Action
{
	private $projects = null;
	
	function init()
	{
		parent::init();
		$this->logger->info('Inicjalizacja strony portfolio sosweb.pl przez użytkownika z IP: '.$_SERVER['REMOTE_ADDR']);
		$this->logger->info('a'.count($this->projects));
	}

	function indexAction()
	{
		$pi_table = new PortfolioItems();
	    $select = $pi_table->select();
		$select->setIntegrityCheck(false)
				->order('is_main DESC')
				->order('valid_from DESC');
		
       	try
       	{
       		$this->logger->info('Fetching projects link items. '.$select->assemble());
			$rows = $pi_table->fetchAll($select);
			$this->projects = $rows;
			$this->getRequest()->setParam('projects', $this->projects);
       	}
		catch(Zend_Exception $ex)
		{
			$this->logger->error($ex->getMessage());
		}
					
		$request = clone $this->getRequest();
        $request->setActionName('portfolio');
        $this->_helper->actionStack($request);

        $request = clone $this->getRequest();
        $request->setActionName('preview');
        $this->_helper->actionStack($request);		
	}
	
	function portfolioAction()
	{
		$this->view->getHelper('HeadLink')->appendStylesheet($this->view->baseUrl.'/public/styles/portfolio.portfolio.css');
	    $this->view->projects = $this->getRequest()->getParam('projects');		
	}
	
	function previewAction()
	{
		$this->view->getHelper('HeadLink')->appendStylesheet($this->view->baseUrl.'/public/styles/portfolio.preview.css');
		$this->view->projects = $this->getRequest()->getParam('projects');
	}
}
?>